#业务类

from page.page_index import PageIndex
from page.page_login import PageLogin
from page.page_user import PageUser

class ServiceLogin(object):
    def __init__(self,driver,base_url):
        #初始化和该业务有关的页面对象们
        self.page_index=PageIndex(driver,base_url)
        self.page_login=PageLogin(driver,base_url)
        self.page_user=PageUser(driver,base_url)


    def service_login_001(self,d):
        self.page_index.openUrl()
        self.page_index.click_login()

        self.page_login.input_zanhao(d["zanhao"])
        self.page_login.input_pwd(d["pwd"])
        self.page_login.click_login()

        siji=self.page_user.getNichenText() #"nswe，欢迎光临"
        yuqi=d["yuqi"]
        return siji==yuqi

    def service_login_002(self,d):
        self.page_index.openUrl()
        self.page_index.click_login()

        self.page_login.input_zanhao(d["zanhao"])
        self.page_login.input_pwd(d["pwd"])
        self.page_login.click_login()

        siji=self.page_login.getPwdClass() #"input_text         invalid-text"
        yuqi=d["yuqi"] #"invalid-text"
        return yuqi in siji

    def service_login_003(self,d):
        self.page_index.openUrl()
        self.page_index.click_login()

        self.page_login.input_zanhao(d["zanhao"])
        self.page_login.input_pwd(d["pwd"])
        self.page_login.click_login()

        return self.page_login.isErrorTipExists()

    def service_login_004(self,d):
        self.page_index.openUrl()
        self.page_index.click_login()

        self.page_login.input_zanhao(d["zanhao"])
        self.page_login.input_pwd(d["pwd"])
        self.page_login.click_login()

        siji=self.page_login.getZanhaoClass()#"input_text    invalid-text"
        yuqi=d["yuqi"]#"invalid-text"
        return yuqi in siji